package com.banmoon.iterator;

import lombok.AllArgsConstructor;
import lombok.NoArgsConstructor;

import java.util.Iterator;
import java.util.List;

@NoArgsConstructor
@AllArgsConstructor
public class BookIterator implements Iterator {

    private List<Book> bookList;

    private int index;

    public BookIterator(List<Book> bookList) {
        this(bookList, -1);
    }

    @Override
    public boolean hasNext() {
        return bookList!=null && bookList.size()>index+1;
    }

    @Override
    public Object next() {
        return bookList.get(++index);
    }
}
